<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('debug', 'Gii');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="backend-module-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php $form = ActiveForm::begin(); ?>
    <?php echo Html::hiddenInput('urlReferrer',!empty($list['urlReferrer']) ? $list['urlReferrer'] : null);?>
    <div class="form-group">
        <?= Html::a('Return List', ['default/index'], ['class' => 'btn btn-secondary']) ?>
        <?= Html::submitButton('Preview', ['name' => 'preview', 'class' => 'btn btn-primary']) ?>

        <?php if (isset($params['files'])): ?>
            <?= Html::submitButton('Generate', ['name' => 'generate', 'class' => 'btn btn-success']) ?>
        <?php endif; ?>
    </div>
    
    <?php if($model->type=='model'):?>
    <?= $form->field($model, 'table_name')->dropDownList($list, ['prompt'=>'----']) ?>
    <?php elseif($model->type=='curd'):?>
    <?= $form->field($model, 'modelClass')->dropDownList($list, ['prompt'=>'----']) ?>
    <?= $form->field($model, 'controller_id')->textInput() ?>
    <?php endif;?>
    <?php
    if (isset($params['results'])) {
        echo $this->render('view/results', [
            'model' => $model,
            'results' => $params['results'],
            'hasError' => $params['hasError'],
        ]);
    } elseif (isset($params['files'])) {
        echo $this->render('view/files', [
            'files' => $params['files'],
            'answers' => $params['files'],
        ]);
    }
    ?>
    <?php ActiveForm::end(); ?>
</div>
<?php $js='$(document).on("click", ".table #check-all", function(){
    $(".table .check").children("input").attr("checked", true);
})';
$this->registerJs($js, \yii\web\View::POS_END);
?>